﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Discount</title>
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="/Scripts/vgo_01.js"></script>
    <link rel="Stylesheet" href="/Content/Style/layoutAll.css" />
    <style type="text/css">
            #SupplierLst
            {
                height:22px;    
            }
        .style1
        {
            width: 345px;
        }
    </style>
    <script>
        function ktngay() {
            var ngay = document.getElementById("NgayBdKm").value;
            var thang = document.getElementById("ThangBdKm").value;
            var nam = document.getElementById("NamBdKm").value;
            var kt = ngay + "/" + thang + "/" + nam;
            var re = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/;
            if (!re.test(kt)) {
                alert('Sai định dạng ngày bắt đầu!!!');
                return false;
            }
            var ngaykt = document.getElementById("NgayKtKm").value;
            var thangkt = document.getElementById("ThangKtKm").value;
            var namkt = document.getElementById("NamKtKm").value;
            var ktkt = ngaykt + "/" + thangkt + "/" + namkt;
            var re1 = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/;
            if (!re1.test(ktkt)) {
                alert('Sai định dạng ngày kết thúc!!!');
                return false;
            }
            return true;

        }
    </script>

</head>
<body>
    <div>
       <center>
            Tạo sự kiện khuyến mãi<br /><br />
             <% if (Session["UserAdmin"] != null)
            {%>
                 Xin chào: <span style="color:Red"><%: Session["UserAdmin"].ToString()%></span><%:Html.ActionLink("Thoát", "AdminLogout", "Admin")%>
             <%}
            else Response.Redirect("/Admin/"); %>
            <br />
           <form method="post" action="/SaveDiscount" id="formID">
                <table>
                <tr>
                    <td>Tiêu đề KM:</td>
                    <td class="style1"><input type="text" name="DiscountTitle" id="DiscountTitle" />&nbsp;<img src="" id="img_tieude" class="img_alert"/>&nbsp;
                    <span id="tieudeErr"></span></td>
                </tr>
                <tr>
                    <td>Nhà Cung cấp thẻ</td>
                    <td class="style1">
                        <% if (ViewData["SupplierLst"] != null)
                           { %>
                           <%: Html.DropDownList("SupplierLst", "--Chọn nhà cung cấp--")%>
                        <%} %>&nbsp;<img src="" id="img_nhaCC" class="img_alert"/><span id="nccErr"></span>
                    </td>
                </tr>
                <tr>
                    <td>Giá trị khuyến mãi:</td>
                    <td class="style1"><input type="text" name="DiscountValue" id="DiscountValue" />% &nbsp;<img src="" id="img_khuyenmai" class="img_alert"/><span id="khuyenmaiErr"></span></td>
                </tr>
                <tr>
                    <td>Ngày bắt đầu</td>
                        <td class="style1"> 
                          <select name="NgayBdKm" id="NgayBdKm">
                            <option id="NgayBd">Ngày</option>
                            <% for (int d = 1; d <= 31; d++)
                                { 
                            %>
                                <% if (d < 10)
                                   { %>
                                <option id="bd_0<%: d%>">0<%: d%></option>  
                                <%}
                                   else
                                   { %>
                                <option id="<%: d %>_bd"><%: d%></option>  
                            <% }
                         } %>
                        </select>/

                        <select name="ThangBdKm" id="ThangBdKm" >
                                <option id="ThangBd">Tháng</option>
                            <% for (int m = 1; m <= 12; m++)
                               { 
                            %>
                                <% if (m < 10)
                                   { %>
                                <option id="tbd_0<%: m%>">0<%: m%></option>  
                                <%}
                                   else
                                   {%>
                                <option id="<%: m %>_tbd"><%: m%></option>  
                            <% }
                               } %>
                        </select>/
                        <select name="NamBdKm" id="NamBdKm">
                                <option id="NamBd">Năm</option>
                            <% for (int y = 1940; y <= int.Parse(DateTime.Now.Year.ToString()); y++)
                                { 
                            %> 
                                <option id="bd_<%: y%>"><%: y%></option>  
                            <% } %>
                        </select>&nbsp;<img src="" id="img_ngaybd" class="img_alert"/>
                          &nbsp;<span id="DateMsgErr"></span></td>
                  
                </tr>
                <tr>
                    <td>Ngày kết thúc: </td>
                    <td class="style1">
                         <select name="NgayKtKm" id="NgayKtKm">
                            <option id="NgayKt">Ngày</option>
                            <% for (int d1 = 1; d1 <= 31; d1++)
                               { 
                            %>
                                <% if (d1 < 10)
                                   { %>
                                <option id="ktKmF_0<%:d1 %>">0<%: d1%></option>  
                                <%}
                                   else
                                   { %>
                                <option id="<%: d1%>_ktKmF"><%: d1%></option>  
                            <% }
                               }%>
                        </select>/
                        <select name="ThangKtKm" id="ThangKtKm" >
                                <option id="ThangKt">Tháng</option>
                            <% for (int m1 = 1; m1 <= 12; m1++)
                               { 
                            %>
                                <% if (m1 < 10)
                                   { %>
                                <option id="tkt_0<%:m1 %>">0<%: m1%></option>  
                                <%}
                                   else
                                   {%>
                                <option id="<%: m1%>_tkt"><%: m1%></option>  
                            <% }
                               }%>
                        </select>/
                        <select name="NamKtKm" id="NamKtKm" onkeyup="return ktngay()";>
                                <option id="NamKt">Năm</option>
                            <% for (int y1 = 1940; y1 <= int.Parse(DateTime.Now.Year.ToString()); y1++)
                                { 
                            %> 
                                <option id="NamKt<%:y1%>"><%: y1%></option>  
                            <% } %>
                        </select> <img src="" id="img_ngaykt" class="img_alert"/>
                       <span id="DateErr"></span></td>
                    
                </tr>
                <tr valign="top">
                    <td>
                        Ghi chú: 
                    </td>
                    <td class="style1">
                        <textarea name="Description" id="Description" style="width:350px; height:100px; max-width:400px; max-height:120px"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td class="style1"><input type="submit" onclick="return ktngay();" /></td>
                    
                </tr>
            </table>
            </form>
        </center>
    </div>
</body>
</html>
